// Saves options to chrome.storage
function save_options() {
  var height = document.getElementById('min-height').value;
  var width = document.getElementById('min-width').value;
  chrome.storage.sync.set({
    minHeight: height,
    minWidth: width
  }, function () {
    // Update status to let user know options were saved.
    var status = document.getElementById('status');
    status.textContent = 'Options saved.';
    status.style.display = 'block';
    setTimeout(function () {
      status.textContent = '';
      status.style.display = 'none';
    }, 750);
  });
}

// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function restore_options() {
  // Use default value color = 'red' and likesColor = true.
  chrome.storage.sync.get({
    minHeight: 350,
    minWidth: 350
  }, function (opt) {
    document.getElementById('min-height').value = opt.minHeight;
    document.getElementById('min-width').value = opt.minWidth;
  });
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);